package com.xiaohe66.web.gateway.http.common;

import com.xiaohe66.common.value.R;
import com.xiaohe66.web.application.common.TagAppService;
import com.xiaohe66.web.application.common.bo.TagSaveBo;
import com.xiaohe66.web.application.common.result.TagResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xiaohe
 * @since 2023.01.29 14:50
 */
@RestController
@RequestMapping("/tag")
public record TagController(TagAppService tagAppService) {

    @GetMapping
    public R<List<TagResult>> list() {

        List<TagResult> tagListResults = tagAppService.listByCurrentAccount();

        return R.ok(tagListResults);
    }

    @PostMapping
    public R<Long> save(@RequestBody TagSaveBo tagSaveBo) {
        return R.ok(tagAppService.save(tagSaveBo));
    }

}
